﻿using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;
using System.Windows.Forms;
using Traceability.Commont.DTOs;

namespace Butcher.winform.EnterpriseForms.SlaughteredDetailnes
{
    public partial class SlaughterCircleList : Form
    {
        public SlaughterCircleList()
        {
            InitializeComponent();
            getList();
        }
        public class pageDTO
        {
            public int pageindex { get; set; }

            public int pagesize { get; set; }
            /// <summary>
            /// 负责人姓名
            /// </summary>
            public string? InChargeofName { get; set; }
            /// <summary>
            /// 待宰圈类型
            /// </summary>
            public string? Slaugthertype { get; set; }
        }
        public void getList()
        {
            string url = @"http://localhost:5229/api/Section/WaitingCircleHtml";
            HttpClient client = new HttpClient();
            pageDTO res = new pageDTO();
            res.pageindex = 1;
            res.pagesize = 3;
            res.InChargeofName = null;
            res.Slaugthertype = null;
            var content = new StringContent(JsonSerializer.Serialize<pageDTO>(res));
            content.Headers.Remove("Content-Type");
            content.Headers.Add("Content-Type", "application/json");
            string result = client.PostAsync(url, content).Result.Content.ReadAsStringAsync().Result;
            JObject info = JObject.Parse(result);
            var saaa = result;
            var aaa = info["lists"].Value<JArray>();
            List<SlaughterCircleSelectDTO> cts = aaa.ToObject<List<SlaughterCircleSelectDTO>>();
            dataGridView1.DataSource = cts;
        }

        private void dataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void button_Click(object sender, EventArgs e)
        {

        }
    }
}
